window.onload = function () {
    var data = window.location.search.substring(1);
    var decodeData = decodeURIComponent(window.atob(data)).split("=")[1];
    var json;
    $.ajax({
        url: "/productInfo!ediProduct", // 请求路径
        type: "POST", //请求方式
        data: {"productQR": decodeData},
        success: function (data) {
            json = JSON.parse(data);
            modify();
        },//响应成功后的回调函数
        error: function () {
            alert("出错啦...")
        },//表示如果请求响应出现错误，会执行的回调函数
        dataType: "json"//设置接受到的响应数据的格式
    });

    function modify() {
        document.getElementById("productQR").value = json.productQR;
        document.getElementById("productType").value = json.productType;
        document.getElementById("productName").value = json.productName;
        document.getElementById("productColor").value = json.productColor;
        document.getElementById("productFactory").value = json.productFactory;
        document.getElementById("productNumber").value = json.productNumber;
        document.getElementById("rsInfo").value = json.saleableInformation;
        document.getElementById("rentPrice").value = json.rentPrice;
        document.getElementById("salePrice").value = json.salePrice;
        document.getElementById("rentMoney").value = json.rentMoney;
        var rpInfo = document.getElementById("rpInfo"); //出租
        var money = document.getElementById("money"); //押金
        var spInfo = document.getElementById("spInfo"); //出售
        rpInfo.style.display = ((json.saleableInformation == 10) || (json.saleableInformation == 11)) ? "block" :
            "none";
        money.style.display = ((json.saleableInformation == 10) || (json.saleableInformation == 11)) ? "block" :
            "none";
        spInfo.style.display = ((json.saleableInformation == 1) || (json.saleableInformation == 11)) ? "block" :
            "none";
        document.getElementById("productDate").value = json.productDate;
        document.getElementById("isBroken").value = json.isBroken;
        document.getElementById("introduction").value = json.introduction;
        document.getElementById("reImg").innerHTML = "<img width='100px' height='100px' src=\"data:image/jpg;base64," + json.productPhoto + "\">";
    }
}